<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改')"/>
</head>
<body>
<form class="layui-form" action=""  th:object="${SignDev}">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
		
						<div class="layui-form-item layui-hide">
		                    <label class="layui-form-label">主键</label>
		                    <div class="layui-input-block">
		                        <input type="text" th:value="*{id}" name="id" lay-verify="title"
		                               autocomplete="off" class="layui-input">
		                    </div>
		                </div>
		                
		                <div class="layui-form-item layui-hide">
		                    <label class="layui-form-label">配置文件路径</label>
		                    <div class="layui-input-block">
		                        <input type="text" th:value="*{confilePath}" name="confilePath" lay-verify="title"
		                               autocomplete="off" class="layui-input">
		                    </div>
		                </div>
		                
		                <div class="layui-form-item layui-hide">
		                    <label class="layui-form-label">日志文件路径</label>
		                    <div class="layui-input-block">
		                        <input type="text" th:value="*{logPath}" name="logPath" lay-verify="title"
		                               autocomplete="off" class="layui-input">
		                    </div>
		                </div>
						
										
		                <div class="layui-form-item">
		                    <label class="layui-form-label">签名设备型号</label>
		                    <div class="layui-input-block">
		                        <select id="devNameId" name="devName" disabled="disabled">
		                            <option th:each="name : ${devNameList}" th:value="${name}" th:text="${name}" th:selected="${name} eq ${SignDev.devName}"></option>
		                        </select>
		                    </div>
		                </div>
					                
										
						<div class="layui-form-item">
		                    <label class="layui-form-label">IP地址</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{ip}" type="text" name="ip" autocomplete="off" placeholder="IP地址" class="layui-input">
		                    </div>
		                </div>
					                
											
										
						<div class="layui-form-item">
		                    <label class="layui-form-label">端口</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{port}" type="number" name="port" autocomplete="off" placeholder="端口" class="layui-input">
		                    </div>
		                </div>
					                
											
										
						<div class="layui-form-item">
		                    <label class="layui-form-label">设备证书号</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{signNo}" type="text" name="signNo" autocomplete="off" placeholder="设备证书号" class="layui-input">
		                    </div>
		                </div>
					                
						<div class="layui-form-item">
						    <label class="layui-form-label">数据类型</label>
						    <div class="layui-input-block">
						      <input type="radio" name="dataType" value=1 title="1" th:checked="${SignDev.dataType eq 1}">
						      <input type="radio" name="dataType" value=0 title="0" th:checked="${SignDev.dataType eq 0}">
						    </div>
						</div>					
										
										
						<div class="layui-form-item">
		                    <label class="layui-form-label">最大连接数</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{connectCount}" type="number" name="connectCount" autocomplete="off" placeholder="最大连接数" class="layui-input">
		                    </div>
		                </div>
					                
											
										
						<div class="layui-form-item">
		                    <label class="layui-form-label">连接超时时间</label>
		                    <div class="layui-input-block">
		                        <input th:value="*{timeOut}" type="number" name="timeOut" autocomplete="off" placeholder="单位：ms" class="layui-input">
		                    </div>
		                </div>
					                
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit=""
                    lay-filter="signDev-update">
                <i class="layui-icon layui-icon-ok"></i>
				提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
				重置
            </button>
        </div>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>
    layui.use(['form','laydate','jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let MODULE_PATH = rootPath+"/auth/SignDevController";
		

        form.on('submit(signDev-update)', function (data) {
        	let loader = layer.load();
            $.ajax({
                url: MODULE_PATH+'/update',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'put',
                success: function (result) {
	console.log(result.successful);
                    if (result.successful) {
                        layer.msg("修改成功，下次启用生效！", {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("signDev-table");
                            layer.close(loader);
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                        layer.close(loader);
                    }
                }
            })
            return false;
        });
    })
</script>
</body>
</html>